$.ajax({
    url:"http://api.jg.com/tried/index",
    type:"post",
    success:function(res){
        var data=JSON.parse(res);
        console.log(data.data[0]);
        var arr = data.data[0];
        var strhtml = '';
        for(var i=0;i<arr.length;i++){
            // console.log(arr[i].eTag1);
            var arrStr = null;
            if( arr[i].eTag1=="" ){
                arrStr = "";
            }else{
                arrStr = '<span class="tag-e tag-zhekou">'+arr[i].eTag1+'</span>';
            }
            strhtml = " <li>\n" +
                "                        <a href=\"\">\n" +
                "                            <div class=\"scroll-cell\">\n" +
                "                                <div class=\"main-img-box\">\n" +
                "                                    <img data-src='https:"+arr[i].imgUrl+"' src alt=\"\">\n" +
                "                                </div>\n" +
                "                                <div class=\"main-desc-box\">\n" +
                "                                    <div class=\"hover-box\">\n" +
                "                                        <div class=\"hover-title\">"+ arr[i].title +"</div>\n" +
                "                                        <div class=\"hover-tag\">\n" +
                "                                            <span class=\"tag-e tag-free\">"+ arr[i].eTag0 +"</span>\n" +arrStr+
                "                                        </div>\n" +
                "                                        <div class=\"hover-number\">\n" +
                "                                             <span class=\"number-apply\">\n" +
                "                                                 <font class=\"red ft-16\">"+ arr[i].peopleNum +"</font>\n" +
                "                                                 参与\n" +
                "                                             </span>\n" +
                "                                            <span class=\"number-query fr\">"+ arr[i].peopleNumfr +"</span>\n" +
                "                                        </div>\n" +
                "                                        <div class=\"hover-hide\">\n" +
                "                                            <div class=\"hover-hide-cell\">\n" +
                "                                                <span class=\"gray\">"+ arr[i].otherTag0 +"</span>\n" +
                "                                                <span class=\"fr\">"+ arr[i].otherTag1 +"</span>\n" +
                "                                            </div>\n" +
                "                                            <div class=\"hover-hide-cell\">\n" +
                "                                                <span class=\"gray\">"+ arr[i].otherTag2 +"</span>\n" +
                "                                                <span class=\"fr\">"+ arr[i].otherTag3 +"</span>\n" +
                "                                            </div>\n" +
                "                                            <div class=\"hover-hide-cell\">\n" +
                "                                                <span class=\"gray\">"+ arr[i].otherTag4 +"</span>\n" +
                "                                                <span class=\"fr\">"+ arr[i].otherTag5 +"</span>\n" +
                "                                            </div>\n" +
                "                                        </div>\n" +
                "                                    </div>\n" +
                "                                </div>\n" +
                "                            </div>\n" +
                "                        </a>\n" +
                "                    </li>";
            if(arr[i].eTag1=="体验师专享"){

            }
            $("#main-ul").append(strhtml);
        }

        var tagE = document.getElementsByClassName("tag-e");
        // console.log(tagE);

        for( var i=0;i<tagE.length;i++ ){
            if( tagE[i].innerText=="免费试用" ){
                tagE[i].classList.add("tag-free")
            }else if( tagE[i].innerText=="体验师专享" ){
                tagE[i].classList.add("tage-common")
            }
        }
    }
})


//导航条点击跳转且被激活状态
var Ul = document.getElementsByClassName('top-ul')[0];
var lis = Ul.children;

Ul.onclick = function (e) {
    for(var i=0;i<lis.length;i++){
        lis[i].classList.remove("open");
    }
    if(e.target.tagName == "A"){
        e.target.parentNode.classList.add("open");
    }
}


var state_ul = document.getElementsByClassName("state_ul")[0];
var state_list = state_ul.children;

state_ul.onclick = function (e){
    for(var j=0;j<state_list.length;j++){
        state_list[j].classList.remove("on");
    }
    if(e.target.tagName == "A"){
        e.target.parentNode.classList.add("on");
    }
}